package day20171108;

import java.util.*;

/**
 * Created by Administrator on 2017-11-8.
 */
public class Test2 {
    public static void main(String[] args) {

        // 三个手机:String数组
        Phone[] phones = new Phone[5];

        phones[0] = new Phone();
        phones[0].brand = "huawei";
        phones[0].price = 8888.88;

        phones[1] = new Phone();
        phones[1].brand = "huawei";
        phones[1].price = 8888.88;

        phones[2] = new Phone();
        phones[2].brand = "huawei";
        phones[2].price = 8888.88;

        phones[3] = new Phone();
        phones[3].brand = "huawei";
        phones[3].price = 8888.88;

        // ctrl + B
        // 集合：List, Map, Set
        List<Phone> phoneList = new ArrayList<Phone>();

        Phone huawei = new Phone();
        huawei.brand = "huawei";
        huawei.price = 88.88;

        Phone iphone = new Phone();
        iphone.brand = "iphone";
        iphone.price = 8888.88;

        phoneList.add(huawei);
        phoneList.add(huawei);
        phoneList.add(iphone);

        System.out.println("List Result");
        // 如何遍历集合
        for (Phone phone : phoneList) {

            System.out.println(phone.brand + " | " + phone.price);

        }


        System.out.println("Set Result");

        Set<Phone> phoneSet = new HashSet<Phone>();
        phoneSet.add(huawei);
        phoneSet.add(huawei);
        phoneSet.add(iphone);

        for (Phone phone : phoneSet) {
            System.out.println(phone.brand + " | " + phone.price);
        }


//        Study study = new StudyImpl();


        /***
         * key      value
         * 1001     chen
         * 1002     zhen
         */
        Map<Long, String> map = new HashMap<>();

        map.put(1001L, "chen");
        map.put(1002L, "zhen");

        for (Map.Entry<Long, String> entry : map.entrySet()){
            entry.getKey();
            entry.getValue();
        }

    }
}
